package android.coocoo.common;

import java.util.ArrayList;

import android.app.Activity;
import android.coocoo.models.CategoryInfo;
import android.coocoo.views.R;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

@SuppressWarnings("unchecked")
public class CategoriesListAdapter extends ArrayAdapter {
		
	Activity context;
	private ArrayList<CategoryInfo> categoriesList;
		
	public CategoriesListAdapter(Activity context, int numberOfTasks) {
		super(context, R.layout.category_info, new String[numberOfTasks]);
		this.context=context;
	}
	
	public CategoriesListAdapter(Activity context, ArrayList<CategoryInfo> categoriesList) {
		super(context, R.layout.task_info_summary, categoriesList);
		Log.e("pass_flag", "CategoriesListAdapter created");
		this.context=context;
		this.categoriesList = categoriesList;
	}
	
	public void setCategoriesList(ArrayList<CategoryInfo> categoriesList) {
		this.categoriesList = categoriesList;
	}

	public ArrayList<CategoryInfo> getCategoriesList() {
		return categoriesList;
	}

	public View getView(final int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater=context.getLayoutInflater();
		View row = convertView;
		if (categoriesList.size() != 0){
			
			row=inflater.inflate(R.layout.category_info, parent, false);
			
			TextView tvCategoryTitle = (TextView)row.findViewById(R.id.tvCategoryTitle);
			tvCategoryTitle.setText(categoriesList.get(position).getTitle());
			
//			TextView tvTitle = (TextView)row.findViewById(R.id.tvTitle);
//			tvTitle.setText("Title");
//			
//			TextView tvContent = (TextView)row.findViewById(R.id.tvContent);
//			tvContent.setText("");
			
			ImageView btDelete = (ImageView)row.findViewById(R.id.btDelete);
			
			return(row);
		}else
			return new View(context);
	}

}